import * as API from '@/constants/api'
import { DRAW_ADDR, PAYMENT_WAY } from '@/constants/mutation-types'
export const state = () => ({
  drawAddr: [],
  paymentWay: []
})
export const mutations = {
  [DRAW_ADDR] (state, result) {
    state.drawAddr = result
  },
  [PAYMENT_WAY] (state, result) {
    state.paymentWay = result
  }
}
export const actions = {
  // 推荐
  async getReferralInfo ({ commit }) {
    return await this.$axios.$post(API.REFERRAL_INFO)
  },
  async getReferralReward ({ commit }) {
    return await this.$axios.$post(API.REFERRAL_REWARD)
  },
  async getReferralRank ({ commit }) {
    return await this.$axios.$post(API.REFERRAL_RANK)
  },
  // 提币地址
  async getAddrList ({ commit }, params) {
    const result = await this.$axios.$post(API.ADDRESS_LIST, params)
    commit(DRAW_ADDR, result.data)
    return result
  },
  async getCoinList ({ commit }, params) {
    return await this.$axios.$post(API.COIN_LIST, params)
  },
  async addAddress ({ commit }, params) {
    return await this.$axios.$post(API.ADD_ADDRESS, params)
  },
  async editAddress ({ commit }, params) {
    return await this.$axios.$post(API.EDIT_ADDRESS, params)
  },
  async delAddress ({ commit }, params) {
    return await this.$axios.$post(API.EDL_ADDRESS, params)
  },
  // 收款方式
  async getGathering ({ commit }, params) {
    const result = await this.$axios.$post(API.GATHERING_LIST, params)
    commit(PAYMENT_WAY, result.data)
    return result
  },
  async getMethod ({ commit }, params) {
    return await this.$axios.$post(API.PROCEED_METHOD, params)
  },
  async getProceed ({ commit }, params) {
    return await this.$axios.$post(API.GET_PROCEED, params)
  },
  async upProceed ({ commit }, params) {
    return await this.$axios.$post(API.UP_PROCEED, params)
  },
  async addProceed ({ commit }, params) {
    return await this.$axios.$post(API.ADD_PROCEED, params)
  },
  async delProceed ({ commit }, params) {
    return await this.$axios.$post(API.DEL_PROCEED, params)
  },
  async getBank ({ commit }, params) {
    return await this.$axios.$post(API.GET_BANK, params)
  },
  // 转账明细
  async recharge ({ commit }, params) {
    return await this.$axios.$post(API.RECHARGE_DETAILS, params)
  },
  async applyLog ({ commit }, params) {
    return await this.$axios.$post(API.APPLY_LOG, params)
  },
  // 检查新版本
  async getVersion ({ commit }, params) {
    return await this.$axios.$post(API.GET_VERSION, params)
  },
  // 消息通知
  async getCate ({ commit }, params) {
    return await this.$axios.$post(API.GET_CATE, params)
  },
  async getMessage ({ commit }, params) {
    return await this.$axios.$post(API.GET_MESSAGE, params)
  }
}
